<!-- 	
	该页面实现链接数据库并显示所有留言信息汇总
	实现技术：MySQLi连接数据库
	连接数据库名称：php_mysql_lyglxt
	连接数据表名称：member
 -->
<?php
	header("Content-Type: text/html;charset=utf-8"); 

	/* Connect to a MySQL server  连接数据库服务器 */
		

	$link = mysqli_connect(
	    'localhost',   /* The host to connect to 连接MySQL地址 */
	    'root',        /* The user to connect as 连接MySQL用户名 */
	    'root',        /* The password to use 连接MySQL密码 */
	    'php_lyglxt');    /* The default database to query 连接数据库名称*/

	//设置数据库字符集
	mysqli_query($link, 'set names utf8');

	//删除数据
	if(@$_GET['t']!=''){
		$a=$_GET['t'];
		mysqli_query($link, $sql="DELETE FROM member WHERE user_id = '$a'");
	}

	//增加数据库内容
   	/*mysqli_query($link, $sql="INSERT INTO member(user_id, user_name, user_tel, user_time, user_text)VALUES(null, '王五','12345678901','','欢迎来到霾都--德州')");
	*/

	if (!$link) {
	    printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
	    exit;
	}else{	
?>
		<table align="center" border="1px">
					<tr>
						<td>序号</td>
						<td>姓名</td>
						<td>电话</td>
						<td>时间</td>
						<td>内容</td>
						<td></td>
					</tr>
	<?php
		if ($result = mysqli_query($link, 'SELECT * FROM member')) {
				while( $row = mysqli_fetch_assoc($result) ){
	?>
					<tr>
						<td><?php echo $row['user_id'] ?></td>
						<td><?php echo $row['user_name'] ?></td>
						<td><?php echo $row['user_tel'] ?></td>
						<td><?php echo $row['user_time'] ?></td>
						<td><?php echo $row['user_text'] ?></td>
						<td width="50px">
							<a href="show.php?t= <?php echo $row['user_id']?>">删除</a>
						</td>
					</tr>
			<?php
				}
			?>
		</table>
	<?php
		}

	}
?>


